<?php
class test{
    public $name='test2';
    public $test2=123;
//    public  function __construct($name)
//    {
//        $this->name=$name;
//    }

    public function test2(){
        echo 222;
    }
}

$test=new test();
$a=$test->name;

echo $test->{$a};